package edu.zzuli.model.xt.pzzc.xtgngl;

import java.io.Serializable;

import javax.annotation.Resource;

import org.apache.struts2.ServletActionContext;
import org.springframework.stereotype.Controller;

import edu.zzuli.model.orm.po.GG_XTGN;
import edu.zzuli.model.xt.pzzc.xtgngl.iface.XtgnglService;

/**
 * @author tianshaojie
 * @date 2011-1-16
 * @discription : 
 */
@SuppressWarnings("serial")
@Controller
public class AddorModGG_XTGNAction implements Serializable{
	
	@Resource
	private XtgnglService xtgnglService;
	
	private GG_XTGN gg_xtgn;
	
	private String ajaxResult;
	
	public String execute() {
		try {
			xtgnglService.saveOrUpdateGG_XTGN(gg_xtgn);
			this.setGg_xtgn(gg_xtgn);
			ajaxResult = "success";
		} catch (Exception e) {
			ajaxResult = "error";
		}
		return ajaxResult;
	}
	
	public String addOrModPage() {
		String id = ServletActionContext.getRequest().getParameter("id");
		if (id != null && !"".equals(id)) {
			gg_xtgn = (GG_XTGN) xtgnglService.selectSinglePO(new GG_XTGN(id));
			ServletActionContext.getRequest().setAttribute("gg_xtgn", gg_xtgn);
		} else {
//			String fid = ServletActionContext.getRequest().getParameter("fid");
			gg_xtgn = new GG_XTGN();
			gg_xtgn.setFid(ServletActionContext.getRequest().getParameter("fid"));
			ServletActionContext.getRequest().setAttribute("gg_xtgn", gg_xtgn);
		}
		return "success";
	}

	public void setAjaxResult(String ajaxResult) {
		this.ajaxResult = ajaxResult;
	}

	public String getAjaxResult() {
		return ajaxResult;
	}

	public void setGg_xtgn(GG_XTGN gg_xtgn) {
		this.gg_xtgn = gg_xtgn;
	}

	public GG_XTGN getGg_xtgn() {
		return gg_xtgn;
	}
}
